import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		$theme: '#44AAEA',
		token: uni.getStorageSync('token') || '',
		userInfo: uni.getStorageSync('userInfo') || {},
		statusBarHeight: uni.getStorageSync('statusBarHeight') || 44
	},
	mutations: {
		setToken(state, value) {
			state.token = value
			uni.setStorageSync('token', value)
		},
		setUserInfo(state, value) {
			state.userInfo = value
			uni.setStorageSync('userInfo', value)
		},
		setStatusBarHeight(state, value) {
			state.statusBarHeight = value
			uni.setStorageSync('statusBarHeight', value)
		},
	}
})

export default store
